//
//  OpenOrderController.m
//  SalonManage
//
//  Created by wulongmin on 17/6/3.
//  Copyright © 2017年 lmtt. All rights reserved.
//

#import "OpenOrderController.h"
#import "SearchViewController.h"


#import "ZHPickView.h"
#import "LM2SelectView.h"


@interface OpenOrderController ()

@property (nonatomic,strong) UIView *contentView;
@property (nonatomic,strong) LMCellView * dataView;
@property (nonatomic,strong) LMCellView * orderView;

@property (nonatomic,strong) LMCellView * customView;//客户姓名
@property (nonatomic,strong) LMCellView * phoneView;//手机号
@property(nonatomic, strong) LM2SelectView *customTypeView;//客户类型

@property (nonatomic,strong) LMCellView * hairstView;//发型师
@property (nonatomic,strong) LMCellView * technicianView;//技师

@property (nonatomic,strong) LMCellView * assistantView;//助理

@property (nonatomic,strong) UILabel * beiginTimeLabel;
@property (nonatomic,strong) UILabel * finishTimeLabel;

@property (nonatomic,strong) LMButton * beginBtn;
@property (nonatomic,strong) LMButton * finishBtn;

@property (nonatomic,strong) LMButton * orderBtn;//调单
@property (nonatomic,strong) LMButton * cancelBtn;//取消
@end

@implementation OpenOrderController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setTitle:@"开单"];
    
    [self initWithSubViews];
}

-(void)initWithSubViews{
    
   self. contentView.frame = CGRectMake(0, 64, __kScreenWidth, __kScreenHeight - 64);
    self.contentView.backgroundColor = HGCOLOR(@"ffffff");
    [self.view addSubview:self.contentView];
    
    [self.contentView addSubview:self.dataView];
    [self.contentView addSubview:self.orderView];
    [self.contentView addSubview:self.customView];
    [self.contentView addSubview:self.phoneView];
    [self.contentView addSubview:self.customTypeView];
    [self.contentView addSubview:self.hairstView];
    [self.contentView addSubview:self.technicianView];
    [self.contentView addSubview:self.assistantView];
    
    [self.contentView addSubview:self.beiginTimeLabel];
    [self.contentView addSubview:self.finishTimeLabel];
    
    [self.contentView addSubview:self.beginBtn];
    [self.contentView addSubview:self.finishBtn];
    
    [self.contentView addSubview:self.orderBtn];
    [self.contentView addSubview:self.cancelBtn];
    
    self.dataView.frame = CGRectMake(HGADPT(30), HGADPT(40), __kScreenWidth/2-HGADPT(60), HGADPT(90));
    self.orderView.frame =  CGRectMake(0, self.dataView.top, self.dataView.width, self.dataView.height);
    self.orderView.right = __kScreenWidth-HGADPT(30);
    
    UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, self.dataView.bottom, __kScreenWidth, HGADPT(5))];
    lineView.backgroundColor = kColorD9D9D9;
    [self.contentView addSubview:lineView];
    
    
    
    self.customView.frame = CGRectMake(HGADPT(30), lineView.bottom, __kScreenWidth-HGADPT(60), HGADPT(90));
   
    self.phoneView.frame = CGRectMake(HGADPT(30), self.customView.bottom, self.customView.width, HGADPT(90));

    self.customTypeView.frame = CGRectMake(HGADPT(30), self.phoneView.bottom, __kScreenWidth-HGADPT(60), HGADPT(90));
    
    
    UIView * lineView2 = [[UIView alloc]initWithFrame:CGRectMake(0, self.customTypeView.bottom, __kScreenWidth, HGADPT(5))];
    lineView2.backgroundColor = kColorD9D9D9;
    [self.contentView addSubview:lineView2];
    self.hairstView.frame = CGRectMake(HGADPT(30), lineView2.bottom, self.customView.width, HGADPT(90));
    self.technicianView.frame = CGRectMake(HGADPT(30), self.hairstView.bottom, self.customView.width, HGADPT(90));
    
    
    UIView * lineView3 = [[UIView alloc]initWithFrame:CGRectMake(0, self.technicianView.bottom, __kScreenWidth, HGADPT(5))];
    lineView3.backgroundColor = kColorD9D9D9;
    [self.contentView addSubview:lineView3];
    self.assistantView.frame = CGRectMake(HGADPT(30), lineView3.bottom, self.customView.width, HGADPT(90));
    

    self.beiginTimeLabel.frame = CGRectMake(HGADPT(30), self.assistantView.bottom+HGADPT(20),self.dataView.width , HGADPT(40));
    
    self.finishTimeLabel.frame = CGRectMake(__kScreenWidth/2 +HGADPT(30), self.assistantView.bottom+HGADPT(20),self.dataView.width , HGADPT(40));
    
    self.beginBtn.frame = CGRectMake(HGADPT(30), self.finishTimeLabel.bottom+HGADPT(200), __kScreenWidth/4-HGADPT(30), HGADPT(80));
    self.finishBtn.frame =CGRectMake(self.beginBtn.right+HGADPT(20), self.beginBtn.top, self.beginBtn.width, self.beginBtn.height);
    
    self.orderBtn.frame =CGRectMake(self.finishBtn.right+HGADPT(20), self.beginBtn.top, self.beginBtn.width, self.beginBtn.height);
    
    self.cancelBtn.frame =CGRectMake(self.orderBtn.right+HGADPT(20), self.beginBtn.top, self.beginBtn.width, self.beginBtn.height);
    
    
    
    
    
}

#pragma mark -懒加载

-(UIView *)contentView{
    if (_contentView == nil) {
        _contentView = [[UIView alloc]init];
    }
    return _contentView;
}
-(LMCellView *)dataView{
    if (_dataView == nil) {
        _dataView = [LMCellView cellViewWithHeight:HGADPT(90) clickHandler:^{
        
    

        }];
        _dataView.detailFied.userInteractionEnabled=NO;
        _dataView.textLabel.text = @"日期";
        _dataView.detailLeft = HGADPT(120);
        NSDate *currentDate = [NSDate date];//获取当前时间，日期
         _dataView.detailFied.text = [BaseViewController stringFromDate:currentDate];
        [_dataView removeLine];
    }
    return _dataView;
}

-(LMCellView *)orderView{
    if (_orderView == nil) {
        _orderView = [LMCellView cellViewWithHeight:HGADPT(90) clickHandler:^{
            
            
        }];
        _orderView.textLabel.text = @"单号";
        _orderView.detailFied.placeholder = @"请输入单号";
        _orderView.detailLeft = HGADPT(120);
         [_orderView removeLine];
    }
    return _orderView;
}

-(LMCellView *)customView{
    if (_customView== nil) {
        _customView = [LMCellView cellViewWithHeight:HGADPT(90) clickHandler:^{
            
            
        }];
        _customView.textLabel.text = @"客户姓名";
        _customView.detailFied.placeholder = @"请输入姓名";
        [_customView removeTopLine];
    }
    return _customView;
}

-(LMCellView *)phoneView{
    if (_phoneView == nil) {
        _phoneView = [LMCellView cellViewWithHeight:HGADPT(90) clickHandler:^{
            
            
        }];
        _phoneView.textLabel.text = @"手机号";
        _phoneView.detailFied.placeholder = @"请输入手机号";
        _phoneView.detailFied.keyboardType = UIKeyboardTypeNumberPad;
        [_phoneView removeTopLine];
    }
    return _phoneView;
}

-(LM2SelectView *)customTypeView{
    if (_customTypeView == nil) {
        _customTypeView =[LM2SelectView selectViewWithTitle:@"服务类型" Left:@"A1" Left2:@"A2" right:@"B1" right2:@"B2"];
        _customTypeView.customType = ^(NSInteger index) {
            
            NSLog(@"客户类型index::::::%ld",(long)index);
        };
    }
    return _customTypeView;
}


-(LMCellView *)hairstView{
    if (_hairstView == nil) {
        _hairstView = [LMCellView cellViewWithHeight:HGADPT(90) clickHandler:^{
            
            
        }];
        _hairstView.textLabel.text = @"发型师";
        _hairstView.detailFied.placeholder = @"请输入发型师编号";
        [_hairstView removeTopLine];
    }
    return _hairstView;
}

-(LMCellView *)technicianView{
    if (_technicianView == nil) {
        _technicianView = [LMCellView cellViewWithHeight:HGADPT(90) clickHandler:^{
            
            
        }];
        _technicianView.textLabel.text = @"技师";
        _technicianView.detailFied.placeholder = @"请输入技师编号";
        [_technicianView removeLine];
    }
    return _technicianView;
}

-(LMCellView *)assistantView{
    if (_assistantView == nil) {
        _assistantView = [LMCellView cellViewWithHeight:HGADPT(90) clickHandler:^{
            
            
        }];
        _assistantView.textLabel.text = @"助理";
        _assistantView.detailFied.placeholder = @"请填写助理编号";
        [_assistantView removeTopLine];
    }
    return _assistantView;
}

-(UILabel *)beiginTimeLabel{
    if (_beiginTimeLabel == nil) {
        _beiginTimeLabel = [[UILabel alloc]init];
        _beiginTimeLabel.font = _kFontMain;
        _beiginTimeLabel.textColor = kColor3C3C3C;
        _beiginTimeLabel.text = @"开始时间 ";
    }
    return _beiginTimeLabel;
}

-(UILabel *)finishTimeLabel{
    if (_finishTimeLabel == nil) {
        _finishTimeLabel = [[UILabel alloc]init];
        _finishTimeLabel.font = _kFontMain;
        _finishTimeLabel.textColor = kColor3C3C3C;
        _finishTimeLabel.text = @"结束时间： ";
    }
    return _finishTimeLabel;
}

-(LMButton *)beginBtn{
    if (_beginBtn == nil) {
        _beginBtn = [LMButton lm_buttonWithType:LMButtonTypeMove title:@"开始计时"];
        kWeakSelf(self)
        _beginBtn.onClick = ^(LMButton *btn) {
             NSDate *currentDate = [NSDate date];//获取当前时间，日期
            weakself.beiginTimeLabel.text = [NSString stringWithFormat:@"开始时间   %@",[BaseViewController stringFromHHMMDate:currentDate]];
        };
    }
    return _beginBtn;
}

-(LMButton *)finishBtn{
    if (_finishBtn == nil) {
        _finishBtn = [LMButton lm_buttonWithType:LMButtonTypeMove title:@"结束计时"];
        kWeakSelf(self)
        _finishBtn.onClick = ^(LMButton *btn) {
            NSDate *currentDate = [NSDate date];//获取当前时间，日期
            weakself.finishTimeLabel.text = [NSString stringWithFormat:@"结束时间   %@",[BaseViewController stringFromHHMMDate:currentDate]];
        };

    
    }
    return _finishBtn;
}


-(LMButton *)orderBtn{
    if (_orderBtn == nil) {
        _orderBtn = [LMButton lm_buttonWithType:LMButtonTypeMove title:@"调单"];
        kWeakSelf(self);
        _orderBtn.onClick = ^(LMButton *btn) {
            SearchViewController * searchVC = [[SearchViewController alloc]init];
            [weakself.navigationController pushViewController:searchVC animated:YES];
            
        };
    }
    return _orderBtn;
}

-(LMButton *)cancelBtn{
    if (_cancelBtn== nil) {
        _cancelBtn = [LMButton lm_buttonWithType:LMButtonTypeMove title:@"取消"];
    }
    return _cancelBtn;
}

@end
